import QtQuick 2.12
import QtQuick.Window 2.3

Item {
    id: container

    property alias text: buttonLabel.text
    property alias label: buttonLabel
    signal clicked()
    property alias containsMouse: hoverHandler.hovered

    property color textColor: "#E1E1E1"
    property color backgroundColor: "#2E75B6"
    property alias radius: frame.radius

    implicitHeight: Math.max(Screen.pixelDensity * 4, buttonLabel.implicitHeight * 0.8)
    implicitWidth: Math.max(Screen.pixelDensity * 11, buttonLabel.implicitWidth * 1.3)
    height: implicitHeight
    width: implicitWidth

    Rectangle {
        id: frame
        anchors.fill: parent
        color: container.enabled ? (container.pressed?Qt.lighter(container.backgroundColor, 1.1):container.backgroundColor)
                                 : "#999"

        antialiasing: true
        radius: height / 8
    }



    Text {
        id: buttonLabel
        text: container.text
        color: container.textColor
        font.pixelSize: container.height * 0.4
        anchors.centerIn: parent
    }

    MouseArea {
        id: masker
        anchors.fill: parent
        onClicked: {
            container.clicked();
        }
    }

    HoverHandler {
        id: hoverHandler
    }
}
